﻿using System;
using System.Windows.Forms;

using AIthin.Controls;


namespace AIthin.Model
{
    public partial class NeuroNetworkForm : Form
    {
        public NeuroNetworkForm()
        {
            InitializeComponent();
        }

        public NeuroNetworkForm(String Path, String FileName):this()
        {
            LoadNetworkFile (Path, FileName);
        }

        private void NeuroNetworkForm_FormClosing(object sender, FormClosingEventArgs e)
        {
          if( MessageBox.Show("Save network?","Attention!",MessageBoxButtons.YesNo) == DialogResult.Yes)
                           this.neuroControl1.SaveNetworkFile(AIthin.Model.Properties.Settings.Default.WorkingPath);
        }

         public void LoadNetworkFile(String Path, String FileName)
        {
            switch (FileName.Substring(FileName.LastIndexOf('.')))
            {
                case ".nw":
                    
                    break;

                case ".nw1":
                    neuroControl1.LoadNetworkFile(Path, FileName);
                    neuroControl1.WorkingPath = AIthin.Model.Properties.Settings.Default.WorkingPath;
                    neuroControl1.Parent = this;
                    this.Text = neuroControl1.NetworkName;
  
                    break;

                default:
                    break;
            }
         
        }

         private void structViewControl1_Load(object sender, EventArgs e)
         {

         }

         private void visualiseToolStripMenuItem_Click(object sender, EventArgs e)
         {
                    NetworkView NWV = new NetworkView();
                    NWV.MdiParent = this.MdiParent;
                    NWV.structViewControl1.LoadNetwork(ref neuroControl1);
                    NWV.Text = neuroControl1.NetworkName;
                    NWV.Show();

         }

         private void NeuroNetworkForm_Load(object sender, EventArgs e)
         {

         }

        
    }
}
